window: Remove initial-focus builder support
authorMatthias Clasen <mclasen@redhat.com>
Sun, 3 Mar 2019 17:31:12 +0000 (12:31 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 17 Mar 2019 01:24:45 +0000 (21:24 -0400)
With focus-widget now a property, this is no longer needed.

gtk/gtkwindow.c
tests/dialog.ui

index a26990f38b3671ef2cc26fe02b06d2ff426e41a8..bf6eeeb6daf3bf4f4b8b1fd051d6ec5827546872 100644 (file)
  * elements representing the #GtkAccelGroup objects you want to add to
  * your window (synonymous with gtk_window_add_accel_group().
  *
- * It also supports the <initial-focus> element, whose name property names
- * the widget to receive the focus when the window is mapped.
- *
  * An example of a UI definition fragment with accel groups:
  * |[
  * <object class="GtkWindow">
  *   <accel-groups>
  *     <group name="accelgroup1"/>
  *   </accel-groups>
- *   <initial-focus name="thunderclap"/>
  * </object>
  * 
  * ...
@@ -2350,55 +2346,6 @@ static const GMarkupParser window_parser =
     window_start_element
   };
 
-typedef struct {
-  GObject *object;
-  GtkBuilder *builder;
-  gchar *name;
-  gint line;
-  gint col;
-} NameSubParserData;
-
-static void
-focus_start_element (GMarkupParseContext  *context,
-                     const gchar          *element_name,
-                     const gchar         **names,
-                     const gchar         **values,
-                     gpointer              user_data,
-                     GError              **error)
-{
-  NameSubParserData *data = (NameSubParserData*)user_data;
-
-  if (strcmp (element_name, "initial-focus") == 0)
-    {
-      const gchar *name;
-
-      if (!_gtk_builder_check_parent (data->builder, context, "object", error))
-        return;
-
-      if (!g_markup_collect_attributes (element_name, names, values, error,
-                                        G_MARKUP_COLLECT_STRING, "name", &name,
-                                        G_MARKUP_COLLECT_INVALID))
-        {
-          _gtk_builder_prefix_error (data->builder, context, error);
-          return;
-        }
-
-      data->name = g_strdup (name);
-      g_markup_parse_context_get_position (context, &data->line, &data->col);
-    }
-  else
-    {
-      _gtk_builder_error_unhandled_tag (data->builder, context,
-                                        "GtkWindow", element_name,
-                                        error);
-    }
-}
-
-static const GMarkupParser focus_parser =
-{
-  focus_start_element
-};
-
 static gboolean
 gtk_window_buildable_custom_tag_start (GtkBuildable  *buildable,
                                        GtkBuilder    *builder,
@@ -2426,21 +2373,6 @@ gtk_window_buildable_custom_tag_start (GtkBuildable  *buildable,
       return TRUE;
     }
 
-  if (strcmp (tagname, "initial-focus") == 0)
-    {
-      NameSubParserData *data;
-
-      data = g_slice_new0 (NameSubParserData);
-      data->name = NULL;
-      data->object = G_OBJECT (buildable);
-      data->builder = builder;
-
-      *parser = focus_parser;
-      *parser_data = data;
-
-      return TRUE;
-    }
-
   return FALSE;
 }
 
@@ -2463,23 +2395,6 @@ gtk_window_buildable_custom_finished (GtkBuildable  *buildable,
 
       g_slice_free (GSListSubParserData, data);
     }
-
-  if (strcmp (tagname, "initial-focus") == 0)
-    {
-      NameSubParserData *data = (NameSubParserData*)user_data;
-
-      if (data->name)
-        {
-          GObject *object;
-
-          object = _gtk_builder_lookup_object (builder, data->name, data->line, data->col);
-          if (object)
-            gtk_window_set_focus (GTK_WINDOW (buildable), GTK_WIDGET (object));
-          g_free (data->name);
-        }
-
-      g_slice_free (NameSubParserData, data);
-    }
 }
 
 static GdkDisplay *
index 93aa2015bc65379fc2af4f58407e2ef125f007a9..baa032ec48f74eaeef6ba9fd1cecfac30fe4e48a 100644 (file)
       <action-widget response="-6">cancel_button</action-widget>
       <action-widget response="apply">confirm_button</action-widget>
     </action-widgets>
-    <initial-focus name="name_entry"/>
   </object>
 </interface>